<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    /**
     * @param {number[]} nums1
     * @param {number} m
     * @param {number[]} nums2
     * @param {number} n
     * @return {void} Do not return anything, modify nums1 in-place instead.
     */
    var merge = function(nums1, m, nums2, n) {
      let nums1Arr = nums1.filter((s1, in1) => {
        return in1 < m;
      });
      let nums2Arr = nums2.filter((s2, in2) => {
        return in2 < n;
      });
      nums1.splice(0, nums1.length, ...[...nums1Arr, ...nums2Arr]);
      nums1.sort((a, b) => {
        // 排序函数
        return a - b;
      });
      return nums1
    };
    console.log(merge([1, 2, 3, 0, 0, 0], 3, [2, 5, 6], 3));
  </script>
</html>
